﻿using System;
using System.Buffers;

namespace Letter.IO.Binary;

public static class BinaryOperationExtensions
{
    public static BytesWriter ToBytesWriter(this IBufferWriter<byte> writer)
    {
        return new BytesWriter(writer);
    }

    public static BytesReader ToBytesReader(this ReadOnlySequence<byte> buf)
    {
        return new BytesReader(ref buf);
    }

    public static SpanReader ToSpanReader(this Span<byte> buf)
    {
        return new SpanReader(buf);
    }
    
    public static SpanReader ToSpanReader(this ReadOnlySpan<byte> buf)
    {
        return new SpanReader(buf);
    }

    public static SpanWriter ToSpanWriter(this Span<byte> buf)
    {
        return new SpanWriter(buf);
    }
}